package org.exercise10.state.impl;

import org.exercise10.state.Context;
import org.exercise10.state.DoorStatus;

/**
 * @author Stranger
 * @version 1.0
 * @description: TODO
 * @date 2022/12/20 17:31
 */
public class ClosedState extends DoorStatus {

    @Override
    public void open() {
        System.out.println("准备开门");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } finally {
            this.context.setState(Context.OPENING_STATE);
            this.context.open();
        }
    }

    @Override
    public void close() {
        System.out.println("门已经关闭");
    }

    @Override
    public void touch() {
        open();
    }

    @Override
    public String toString() {
        return "门已关闭";
    }
}
